import time

from appium.webdriver.common.mobileby import MobileBy
from Hogwarts.Homeworks.hw0701.page_objects.base import Base


"""
PAGE：录入成员信息
"""


class PageContactAddEdit(Base):

    _INPUT_MEMBER_NAME = (MobileBy.ID, "com.tencent.wework:id/b09")
    _INPUT_MOBILE_NUM = (MobileBy.ID, "com.tencent.wework:id/f7y")
    _BTN_SAVE = (MobileBy.ID, "com.tencent.wework:id/ad2")

    def edit_member(self, member_name, mobile_num):
        """
        录入成员信息
        :return:
        """
        from Hogwarts.Homeworks.hw0701.page_objects.page_contact import PageContact

        self.find(*self._INPUT_MEMBER_NAME).send_keys(member_name)
        self.find(*self._INPUT_MOBILE_NUM).send_keys(mobile_num)
        self.find_and_click(*self._BTN_SAVE)

        # 执行返回上一层
        time.sleep(2)
        self.driver.back()

        return PageContact(self.driver)
